/*
 * @Author: zhangxin 411020991@qq.com
 * @Date: 2023-04-10 16:59:11
 * @LastEditors: zhangxin 411020991@qq.com
 * @LastEditTime: 2023-04-19 09:38:18
 * @FilePath: \main\src\components\Locales\index.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import React from 'react'
import { Dropdown, Space } from 'antd';
import { DownOutlined } from '@ant-design/icons';
import { setLocale, getLocale, FormattedMessage } from '@umijs/max';
import { useIntl } from '@umijs/max';
const index = () => {
    const intl = useIntl()
    const items = [
        {
            label: <span>简称中文</span>,
            key: 'zh-CN',
        },
        {
            label: <span>English</span>,
            key: 'en-US',
        },
        {
            label: <span>繁體中文</span>,
            key: 'zh-TW',
        },
        {
            label: <span>日本語</span>,
            key: 'ja-JP',
        },
        {
            label: <span>한국어</span>,
            key: 'fa-IR',
        },
    ];
    //    切换语言
    const localeTion = (e) => {
        console.log(e);
        setLocale(e.key)
    }

    return (
        <><Dropdown
            menu={{
                items,
                onClick: localeTion
            }}
            trigger={['click']}
        >
            <span>
                <Space>
                    {intl.formatMessage({
                        id: 'TEXT_49',
                        defaultMessage: '语言'
                    })}
                    <DownOutlined />
                </Space>
            </span>
        </Dropdown ></>
    )
}

export default index
